const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    talkDetail: {},
    
    hidden: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var talkId=options.talkid;
    console.log("talkId:", talkId);
    that.talkDetail(talkId);
    
  },

  talkDetail: function (talkId) {
    var that = this;
    wx.request({
      url: app.globalData.baseUrl + '/talk/getTalk',
      method: 'GET',
      data: {
        talkId: talkId
      },//传入的参数
      success: function (res) {
        var list = res.data.talk;
        if (list == null) {
          var toastText = '获取数据失败';
          wx.showToast({
            title: toastText,
            icon: '',
            duration: 2000
          });
        } else {
          if (list.picture != '' && list.picture != 'null' && list.picture != null) {
          console.log("picture:", list.picture)
          var imagesList = list.picture.split(",");
          console.log("imagesList:", imagesList)
          for (var i = 0; i < imagesList.length; i++) {
            imagesList[i] = app.globalData.baseUrl + imagesList[i];
          }
          that.setData({

            imagesList: imagesList,

          });
          }
          that.setData({
            talkDetail: list,
            hidden: true
          });
          console.log('talk:' + list);
        }
      }
    })

  },

  /**
   * 预览图片方法
   */
  listenerButtonPreviewImage: function (e) {
    let that = this;
    let imagesList = that.data.imagesList;
    let url = e.target.dataset.url;
    console.log(url);

    wx.previewImage({
      current: url,
      urls: imagesList,

      //这根本就不走
      success: function (res) {
        //console.log(res);
      },
      //也根本不走
      fail: function () {
        //console.log('fail')
      }
    })
  },

  
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  
})